import json

def array():
    with open("data.json") as f:
        return json.load(f)


# print(array()[0])    
# {'name': 'infomation-tips', 'path': 'linux-other-tools/infomation-tips'}

# for i in array():
#     print(i)
# {'name': 'infomation-tips', 'path': 'linux-other-tools/infomation-tips'}
# {'linkfile': [{'dest': 'Makefile', 'src': 'repo-qt.mk'}], 'name': 'manifests.build-scripts', 'path': 'build-scripts'}
# {'name': 'qgo.platformio-analyzer', 'path': 'linux-other-tools/qgo-platformio-analyzer'}
# {'name': 'qt-notify', 'path': 'widgets/qt-notify'}
# {'name': 'qt.android-adb-fastboot-tools', 'path': 'linux-good-tools/android-adb-fastboot-tools'}
# {'name': 'qt.android-repo-analyzer', 'path': 'linux-good-tools/android-repo-analyzer'}
# {'name': 'qt.appimage-hub-search', 'path': 'useless-tools/appimage-hub-search'}
# {'name': 'qt.bmxc-cpu', 'path': 'useless-tools/bmxc-cpu'}
# {'name': 'qt.clipboard-history-analyzer', 'path': 'development/linux-tools/qt.clipboard-history-analyzer'}
# {'name': 'qt.cmake-vcpkg-analyzer', 'path': 'development/linux-tools/qt.cmake-vcpkg-analyzer'}
# {'name': 'qt.debian-apt-analyzer', 'path': 'development/linux-tools/qt.debian-apt-analyzer'}
# {'name': 'qt.deepin-wallpaper-quiksetting', 'path': 'linux-deepin/deepin-wallpaper-quiksetting'}

# tree
# │   │   │   ├── notificationinhibition.cpp
# │   │   │   ├── notificationinhibition.h
# │   │   │   ├── org.kde.KWin.TabletModeManager.xml
# │   │   │   ├── org.kde.KWin.VirtualKeyboard.xml
# │   │   │   ├── outputsmodel.cpp
# │   │   │   ├── outputsmodel.h
# │   │   │   ├── PipeWireDelegate.qml
# │   │   │   ├── portalicon.cpp
# │   │   │   ├── portalicon.h
# │   │   │   ├── print.cpp
# │   │   │   ├── print.h
# │   │   │   ├── quickdialog.cpp
# │   │   │   ├── quickdialog.h
# │   │   │   ├── region-select
# │   │   │   │   ├── FloatingBackground.qml
# │   │   │   │   ├── FloatingTextBox.qml
# │   │   │   │   ├── RegionSelectOverlay.qml
# │   │   │   │   ├── SelectionEditor.cpp
# │   │   │   │   └── SelectionEditor.h
# │   │   │   ├── remotedesktop.cpp
# │   │   │   ├── remotedesktopdialog.cpp
# │   │   │   └── xdgshortcut.h
# │   │   └── TODO
# │   ├── xdg-desktop-portal-kde_6.3.5-1.debian.tar.xz
# │   ├── xdg-desktop-portal-kde_6.3.5-1.dsc
# │   ├── xdg-desktop-portal-kde_6.3.5.orig.tar.xz
# │   └── xdg-desktop-portal-kde_6.3.5.orig.tar.xz.asc
# ├── vboxdrv-Module.symvers
# ├── VMwareDnD
# └── vscode-typescript1000
#     └── 0f3a0f9a2821e9bc2b29


# parent = "│   "
# child = "├── "
# end = "└── "


def generate_markdown_nodes(projects):

    class DNode:
        def __init__(self):
            self.children = {}
            self.has_project = False

    root = DNode()

    for project in projects:
        path = project["path"]
        parts = project["path"].split("/")

        current = root

        for part in parts:
            if part not in current.children:
                current.children[part] = DNode()
            current = current.children[part]
        